<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button>变宽</button>
    <button>变高</button>
    <button>变色</button>
    <button>隐藏</button>
    <button>重置</button>

    <div id="box">

    </div>
</body>
<script>
    let but = document.getElementsByTagName('button');
    let box = document.getElementById('box')
    let obj = { width: 300, height: 300, color: 'red' }
    box.style.width = 100 + 'px'
    box.style.backgroundColor = '#000000'
    box.style.height = 100 + 'px'

    for (let i = 0; i < but.length; i++) {
        but[i].onclick = function () {
            switch (i) {
                case 0:
                    box.style.width = obj.width + 'px'
                    break;
                case 1:
                    box.style.height = obj.height + 'px'
                    break;
                case 2:
                    box.style.backgroundColor = obj.color
                    break;
                case 3:
                    box.style.display = 'none'
                    break;
                case 4:
                    box.style.width = 100 + 'px'
                    box.style.backgroundColor = '#000000'
                    box.style.height = 100 + 'px'
                    box.style.display = 'block'
                    break;
                default:
                    break;
            }
        }
    }
</script>

</html>